//
//  TabBarViewController.m
//  BeiBei
//
//  Created by mac on 16/7/27.
//  Copyright © 2016年 Yh. All rights reserved.
//

#import "TabBarViewController.h"

#import "PageViewController.h"

#import "DiscountViewController.h"

#import "SelectedViewController.h"

#import "CartViewController.h"

#import "MyViewController.h"

@interface TabBarViewController ()

@end

@implementation TabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    PageViewController * svc = [[PageViewController alloc]init];
    UIImage * svcImage = [self imageWithName:@"yuike_maintab_home_nor"];
    UIImage * svcImageNormal = [self imageWithName:@"yuike_maintab_home_sel"];
    svc.tabBarItem.image = svcImage;
    svc.tabBarItem.selectedImage = svcImageNormal;
    svc.tabBarItem.imageInsets = UIEdgeInsetsMake(5, 0, -5, 0);
    UINavigationController * svcNav = [[UINavigationController alloc]initWithRootViewController:svc];
    
    DiscountViewController * pvc = [[DiscountViewController alloc]init];
    UIImage * pvcImage = [self imageWithName:@"yuike_maintab_ninenine_nor"];
    UIImage * pvcImageNormal = [self imageWithName:@"yuike_maintab_ninenine_sel"];
    pvc.tabBarItem.image = pvcImage;
    pvc.tabBarItem.selectedImage = pvcImageNormal;
    pvc.tabBarItem.imageInsets = UIEdgeInsetsMake(5, 0, -5, 0);
    UINavigationController * pvcNav = [[UINavigationController alloc]initWithRootViewController:pvc];
    
    SelectedViewController * gvc = [[SelectedViewController alloc]init];
    UIImage * gvcImage = [self imageWithName:@"yuike_maintab_gquality_nor"];
    UIImage * gvcImageNormal = [self imageWithName:@"yuike_maintab_gquality_sel"];
    gvc.tabBarItem.image = gvcImage;
    gvc.tabBarItem.selectedImage = gvcImageNormal;
    gvc.tabBarItem.imageInsets = UIEdgeInsetsMake(5, 0, -5, 0);
    UINavigationController * gvcNav = [[UINavigationController alloc]initWithRootViewController:gvc];
    
    CartViewController * cvc = [[CartViewController alloc]init];
    UIImage * cvcImage = [self imageWithName:@"yuike_maintab_shopcart_nor"];
    UIImage * cvcImageNormal = [self imageWithName:@"yuike_maintab_shopcart_sel"];
    cvc.tabBarItem.image = cvcImage;
    cvc.tabBarItem.selectedImage = cvcImageNormal;
    cvc.tabBarItem.imageInsets = UIEdgeInsetsMake(5, 0, -5, 0);
    UINavigationController * cvcNav = [[UINavigationController alloc]initWithRootViewController:cvc];
    
    MyViewController * mvc = [[MyViewController alloc]init];
    UIImage * mvcImage = [self imageWithName:@"yuike_maintab_space_nor"];
    UIImage * mvcImageNormal = [self imageWithName:@"yuike_maintab_space_sel"];
    mvc.tabBarItem.image = mvcImage;
    mvc.tabBarItem.selectedImage = mvcImageNormal;
    mvc.tabBarItem.imageInsets = UIEdgeInsetsMake(5, 0, -5, 0);
    UINavigationController * mvcNav = [[UINavigationController alloc]initWithRootViewController:mvc];
    
    self.viewControllers = @[svcNav,pvcNav,gvcNav,cvcNav,mvcNav];
    
}

- (void)colorWithItem:(UITabBarItem *)item
{
    [item setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor blackColor]} forState:UIControlStateNormal];
    
    [item setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor redColor]} forState:UIControlStateSelected];
}
- (UIImage *)imageWithName:(NSString *)name
{
    UIImage * image = [[UIImage imageNamed:name]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    return image;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
